<template>
  <!--  独立配置新增按钮弹出层-->
  <el-dialog
    :title="title"
    :visible.sync="open"
    direction="rtl"
  >
    <el-container>
      <el-main>
        <el-form ref="form" :model="form" :rules="rules" label-width="80px">

          <!-- 新增配置 -->
          <el-form-item label="serverId" prop="serverId">
            <el-input v-model="form.serverId" placeholder="请输入serverId"/>
          </el-form-item>

        </el-form>

      </el-main>
      <el-footer>
        <div class="bottom-bar" style="text-align: right">
          <el-button @click="handleCancel">取 消</el-button>
          <el-button type="primary" @click="handleSubmit">确 定</el-button>
        </div>
      </el-footer>
    </el-container>
  </el-dialog>
</template>

<script>
export default {
  name: 'NetworkServerId',
  data() {
    return {
      title: '新增',
      open: false,
      form: {},
      // 表单校验
      rules: {
        serverId: [
          { required: true, message: '请输入serverId', trigger: 'blur' }
        ]
      },
    }
  },
  methods: {
    // 表单重置
    reset() {
      this.form = {}
      this.resetForm('form')
    },
    /** 打开操作 */
    handleOpen() {
      this.open = true
    },
    /** 取消按钮操作 */
    handleCancel() {
      this.open = false
      this.reset()
    },
    /** 提交按钮操作 */
    handleSubmit() {
      this.$refs['form'].validate(valid => {
        if (valid) {
          this.$emit('submit', this.form.serverId)
          this.open = false
          this.reset()
        }
      })
    }
  }
}
</script>

<style scoped>

</style>
